package com.gofunbuy.app.home;

import com.gofunbuy.MainActivity;
import com.gofunbuy.R;
import com.gofunbuy.util.GoFunBuyUtils;
import com.gofunbuy.util.GoFunBuyUtils.GoFunBuyInterface;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class HomeActivity extends Activity implements OnClickListener,
		GoFunBuyInterface {
	private Button btAboutUS, btBooking, btMember, btStore, btFavorable,
			btOthers;
	private Context mContext;
	// 切换当前显示的图片
	private Handler handler = new Handler() {
		public void handleMessage(android.os.Message msg) {
		};
	};

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mContext = this;
		setContentView(R.layout.home_layout);
		initLayout();
	}

	private void initLayout() {
		btAboutUS = (Button) findViewById(R.id.id_home_about_us);
		btBooking = (Button) findViewById(R.id.id_home_book);
		btMember = (Button) findViewById(R.id.id_home_member);
		btStore = (Button) findViewById(R.id.id_home_store);
		btFavorable = (Button) findViewById(R.id.id_home_favourable);
		btOthers = (Button) findViewById(R.id.id_home_other);

		btAboutUS.setOnClickListener(this);
		btBooking.setOnClickListener(this);
		btMember.setOnClickListener(this);
		btStore.setOnClickListener(this);
		btFavorable.setOnClickListener(this);
		btOthers.setOnClickListener(this);
	}

	@Override
	protected void onStart() {
		super.onStart();
	}

	@Override
	protected void onStop() {
		super.onStop();
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.id_home_about_us:

			startExactTabActivity(TAB_HOME);
			break;
		case R.id.id_home_book:
			startExactTabActivity(TAB_BOOKING);
			break;
		case R.id.id_home_member:
			startExactTabActivity(TAB_MEMBER);
			break;
		case R.id.id_home_store:
			startExactTabActivity(TAB_SHOPING);
			break;
		case R.id.id_home_favourable:
			startExactTabActivity(TAB_FAVORABLE);
			break;
		case R.id.id_home_other:
			startExactTabActivity(TAB_OHTERS);
			break;
		}
	}

	private void startExactTabActivity(int pose) {
		Intent it = new Intent(this, MainActivity.class);
		it.putExtra(TAB_POSE, pose);
		if (pose != 0)
			it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		startActivity(it);
		finish();
	}
}
